package com.springboot.controller;

import com.springboot.domain.User;
import com.springboot.service.UserServceI;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/uc")
public class UserController {

    @Resource(name="userServceI")
    private UserServceI usi;

    @RequestMapping("/find")
    @ResponseBody
    public List<User> find(User u){
        return usi.findUser(u);
    }

    @RequestMapping("/addUser")
    public Map<String,Object> addUser(User u){
        return usi.addUser(u);
    }
    @RequestMapping("/editUser")
    public Map<String,Object> editUser(User u){
        return usi.editUser(u);
    }

    @RequestMapping("/removeUser/{id}")
    public Map<String,Object> removeUser(@PathVariable(value = "id") int id){
        return usi.removeUser(id);
    }

    @RequestMapping("/find2")
    public List<User> find2(){
        List<User> list = usi.findUser2();
        return list;
    }
    @RequestMapping("/find3")
    public List<User> find3(){
        List<User> list = usi.findUser3();
        return list;
    }


}
